package com.d0323;

import java.util.Objects;

public class Course2 {
    private String title;
    private int price;




    @Override
    public boolean equals(Object obj) {
        if (this ==obj){
            return true;
        }if (obj==null){
            return false;
        }if (this.getClass()!=obj.getClass()){
            return false;
        }

        Course2 course2=(Course2)obj;
        if (this.price!=course2.price){
            return false;
        }
        if (title==null){
            if (course2.title!=null){
                return false;
            }else if (!title.equals(course2.title)){
                return false;
            }
        }
        return  true;
    }

    public Course2(String title, int price) {
        this.title = title;
        this.price = price;
    }

    public static void main(String[] args) {
        Course2 course= new Course2("math",100);
        Course2 course1=new Course2("math",100);
        System.out.println(course==course1);
        System.out.println(course.equals(course1));
    }
}
